import api from '@/api/api'
import type { Product } from '@/type/product.ts'
import type PageOut from '@/type/page-out.ts'
import type PageIn from '@/type/page-in.ts'

const PRODUCT_URI = {
  LIST: '/product/list',
  CREATE: '/product/create',
  MODIFY: '/product/modify',
  DELETE: '/product/delete',
}


// 用户相关API封装
export const productApi = {

  list(page: PageIn<never>) : Promise<PageOut<Product[]>> {
    return api.post(PRODUCT_URI.LIST, page)
  },

  create(product: Product) {
    return api.post(PRODUCT_URI.CREATE, product)
  },

  modify(product: Product) {
    return api.post(PRODUCT_URI.MODIFY, product)
  },

  delete(id: string) {
    return api.post(PRODUCT_URI.DELETE, id)
  },

}

export default productApi
